<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>小区房源地图</title>
    <!-- 引入 Font Awesome 图标库 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"/>
    <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css"/>
    <style>
        /* 全局样式重置和基础设置 */
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        html, body, #container {
            height: 100%;
            width: 100%;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        /* 页面标题栏 */
        .header {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 60px;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            z-index: 1001;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0 20px;
        }

        .header h1 {
            color: #333;
            font-size: 20px;
            font-weight: 600;
            margin: 0;
            text-align: center;
            flex: 1;
        }

        .header-icon {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 40px;
            height: 40px;
            color: #667eea;
            font-size: 20px;
        }

        /* 房源信息面板样式 */
        .house-info-panel {
            position: fixed;
            bottom: 20px;
            left: 20px;
            right: 20px;
            max-height: 45%;
            background: rgba(255, 255, 255, 0.97);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
            padding: 24px;
            overflow-y: auto;
            display: none;
            z-index: 1000;
            transform: translateY(30px);
            opacity: 0;
            transition: transform 0.4s ease, opacity 0.4s ease;
        }

        .house-info-panel.show {
            display: block;
            transform: translateY(0);
            opacity: 1;
        }

        /* 滚动条美化 */
        .house-info-panel::-webkit-scrollbar {
            width: 6px;
        }

        .house-info-panel::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.05);
            border-radius: 3px;
        }

        .house-info-panel::-webkit-scrollbar-thumb {
            background: rgba(102, 126, 234, 0.3);
            border-radius: 3px;
        }

        .house-info-panel::-webkit-scrollbar-thumb:hover {
            background: rgba(102, 126, 234, 0.5);
        }

        .house-info-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 16px;
            border-bottom: 2px solid #f5f7ff;
        }

        .house-info-header h3 {
            margin: 0;
            color: #333;
            font-size: 18px;
            font-weight: 700;
            display: flex;
            align-items: center;
        }

        .house-info-header h3 i {
            color: #667eea;
            margin-right: 8px;
            font-size: 16px;
        }

        .close-btn {
            background: #f5f7ff;
            border: none;
            font-size: 20px;
            cursor: pointer;
            color: #667eea;
            padding: 0;
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: all 0.3s ease;
            box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
        }

        .close-btn:hover {
            background: #667eea;
            color: white;
            transform: rotate(90deg);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
        }

        /* 房源项样式 */
        .house-item {
            padding: 16px;
            border-radius: 12px;
            margin-bottom: 12px;
            background: white;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
            position: relative;
            overflow: hidden;
        }

        .house-item:last-child {
            margin-bottom: 0;
        }

        .house-item:hover {
            background: #f8faff;
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(102, 126, 234, 0.15);
        }

        .house-item::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 4px;
            height: 100%;
            background: linear-gradient(to bottom, #667eea, #764ba2);
        }

        .house-title {
            font-size: 17px;
            font-weight: 600;
            color: #333;
            margin-bottom: 8px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-left: 8px;
        }

        .house-price {
            color: #e74c3c;
            font-size: 20px;
            font-weight: 700;
            text-shadow: 0 1px 2px rgba(231, 76, 60, 0.1);
        }

        .house-info {
            font-size: 14px;
            color: #666;
            line-height: 1.6;
            padding-left: 8px;
        }

        .house-info p {
            margin-bottom: 6px;
        }

        .house-info p:last-child {
            margin-bottom: 0;
            color: #888;
        }

        /* 房源标签 */
        .house-tags {
            display: flex;
            flex-wrap: wrap;
            margin-top: 10px;
            padding-left: 8px;
        }

        .house-tag {
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 12px;
            margin-right: 6px;
            margin-bottom: 4px;
            background: #f0f4ff;
            color: #667eea;
        }

        /* 小区标记点动画效果 */
        .community-marker {
            position: relative;
            transform-origin: center;
            animation: markerFloat 3s ease-in-out infinite;
        }

        @keyframes markerFloat {
            0%, 100% {
                transform: translateY(0);
            }
            50% {
                transform: translateY(-8px);
            }
        }

        .marker-pulse {
            position: absolute;
            top: 50%;
            left: 50%;
            width: 40px;
            height: 40px;
            margin: -20px 0 0 -20px;
            background: rgba(102, 126, 234, 0.3);
            border-radius: 50%;
            animation: pulse 2s infinite;
            z-index: -1;
        }

        .marker-pulse:nth-child(2) {
            animation-delay: 0.5s;
        }

        @keyframes pulse {
            0% {
                transform: scale(0);
                opacity: 1;
            }
            100% {
                transform: scale(2);
                opacity: 0;
            }
        }

        .marker-content {
            width: 32px;
            height: 32px;
            background: linear-gradient(135deg, #667eea, #764ba2);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 14px;
            font-weight: 700;
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
            border: 3px solid white;
        }

        /* 统计信息面板 */
        .stats-panel {
            position: fixed;
            top: 80px;
            right: 20px;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border-radius: 12px;
            padding: 16px;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
            z-index: 999;
            min-width: 200px;
        }

        .stats-panel h4 {
            font-size: 14px;
            color: #666;
            margin-bottom: 12px;
            text-align: center;
            font-weight: 600;
        }

        .stat-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 6px 0;
            font-size: 13px;
            border-bottom: 1px solid #f5f5f5;
        }

        .stat-item:last-child {
            border-bottom: none;
        }

        .stat-label {
            color: #888;
        }

        .stat-value {
            color: #667eea;
            font-weight: 700;
            font-size: 14px;
        }

        /* 移动端响应式设计 */
        @media (max-width: 768px) {
            .header h1 {
                font-size: 18px;
            }

            .house-info-panel {
                bottom: 10px;
                left: 10px;
                right: 10px;
                padding: 20px;
            }

            .stats-panel {
                top: 70px;
                right: 10px;
                min-width: 180px;
                padding: 12px;
            }

            .house-title {
                font-size: 16px;
            }

            .house-price {
                font-size: 18px;
            }

            .house-info {
                font-size: 13px;
            }

            .vr-view-btn {
                width: 100%;
                padding: 10px;
            }
        }

        /* VR看房按钮样式 */
        .vr-view-btn {
            background: linear-gradient(135deg, #4facfe, #00f2fe);
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 20px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 600;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
            box-shadow: 0 4px 12px rgba(79, 172, 254, 0.3);
        }

        .vr-view-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(79, 172, 254, 0.4);
            background: linear-gradient(135deg, #3a8ff9, #00c4ff);
        }

        .vr-view-btn i {
            margin-right: 6px;
        }

        /* VR看房模态框样式 */
        .vr-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.9);
            z-index: 2000;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .vr-modal.show {
            display: flex;
        }

        .vr-modal-content {
            background: white;
            border-radius: 16px;
            width: 100%;
            max-width: 1200px;
            max-height: 90vh;
            overflow: hidden;
            position: relative;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
            animation: modalOpen 0.4s ease;
        }

        @keyframes modalOpen {
            from {
                opacity: 0;
                transform: scale(0.9) translateY(20px);
            }
            to {
                opacity: 1;
                transform: scale(1) translateY(0);
            }
        }

        .vr-modal-header {
            padding: 20px;
            background: linear-gradient(135deg, #4facfe, #00f2fe);
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .vr-modal-header h3 {
            margin: 0;
            font-size: 20px;
        }

        .vr-modal-close {
            background: rgba(255, 255, 255, 0.2);
            border: none;
            color: white;
            font-size: 24px;
            cursor: pointer;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
        }

        .vr-modal-close:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: rotate(90deg);
        }

        .vr-view-container {
            height: calc(90vh - 80px);
            background: #1a1a1a;
            position: relative;
            overflow: hidden;
        }

        .vr-loading {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #0a0a0a;
            z-index: 10;
            transition: opacity 0.5s ease;
        }

        .vr-loading.hidden {
            opacity: 0;
            pointer-events: none;
        }

        .vr-loading-content {
            text-align: center;
            color: white;
        }

        .vr-loading-icon {
            font-size: 48px;
            margin-bottom: 16px;
            animation: spin 2s linear infinite;
            color: #00f2fe;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .vr-nav-buttons {
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            display: flex;
            justify-content: space-between;
            padding: 20px;
            transform: translateY(-50%);
            z-index: 5;
        }

        .vr-nav-btn {
            background: rgba(255, 255, 255, 0.2);
            border: 2px solid white;
            color: white;
            font-size: 24px;
            cursor: pointer;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
        }

        .vr-nav-btn:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: scale(1.1);
        }

        @media (max-width: 768px) {
            .vr-modal-content {
                max-width: 100%;
                max-height: 100vh;
                border-radius: 0;
            }

            .vr-view-container {
                height: calc(100vh - 80px);
            }
        }
    </style>
</head>
<body>
<div id="container"></div>

<!-- 页面标题栏 -->
<div class="header">
    <div class="header-icon">
        <i class="fas fa-map-marker-alt"></i>
    </div>
    <h1>小区房源地图</h1>
    <div class="header-icon">
        <i class="fas fa-home"></i>
    </div>
</div>

<!-- 统计信息面板 -->
<div class="stats-panel">
    <h4>房源统计</h4>
    <div class="stat-item">
        <span class="stat-label">小区总数</span>
        <span class="stat-value">5</span>
    </div>
    <div class="stat-item">
        <span class="stat-label">房源总数</span>
        <span class="stat-value">10</span>
    </div>
    <div class="stat-item">
        <span class="stat-label">平均价格</span>
        <span class="stat-value">787万</span>
    </div>
</div>

<!-- 房源信息面板 -->
<div id="houseInfoPanel" class="house-info-panel">
    <div class="house-info-header">
        <h3 id="communityName"><i class="fas fa-building"></i> 小区名称</h3>
        <button class="close-btn" onclick="closeHouseInfo()">×</button>
    </div>
    <div id="houseList"></div>
</div>

<script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=4db26101de8e63feaa53e36502fa4a4a"></script>
<script>
    // 模拟小区数据
    const communityData = [
        {
            id: 1,
            name: "阳光小区",
            position: [116.478935, 39.997761],
            description: "阳光小区位于北京市朝阳区，环境优美，交通便利",
            tags: ["地铁沿线", "学区房", "绿化率高"]
        },
        {
            id: 2,
            name: "和谐家园",
            position: [116.478939, 39.998525],
            description: "和谐家园是成熟社区，配套设施完善，生活便利",
            tags: ["成熟社区", "医疗配套", "生活便利"]
        },
        {
            id: 3,
            name: "幸福里",
            position: [116.479658, 39.998528],
            description: "幸福里小区绿化率高，物业管理完善，适合居住",
            tags: ["物业管理好", "宜居社区", "近商场"]
        },
        {
            id: 4,
            name: "城市花园",
            position: [116.480784, 39.998302],
            description: "城市花园紧邻城市公园，空气清新，环境宜人",
            tags: ["公园旁", "环境优美", "空气清新"]
        },
        {
            id: 5,
            name: "金色年华",
            position: [116.482072, 39.997718],
            description: "金色年华是高端小区，安保严格，私密性好",
            tags: ["高端社区", "安保严格", "智能家居"]
        }
    ];

            // 模拟房源数据
    const mockHouseData = {
        1: [
            {
                id: 101,
                title: "阳光小区 3室2厅2卫",
                area: "120㎡",
                layout: "南北通透",
                price: "750万",
                floor: "15/32层",
                year: "2015年",
                description: "精装修，拎包入住，采光好，视野开阔",
                tags: ["精装修", "拎包入住", "采光好", "视野开阔"],
                vrAvailable: true,
                vrCode: "sunshine-101"
            },
            {
                id: 102,
                title: "阳光小区 2室1厅1卫",
                area: "89㎡",
                layout: "南向",
                price: "520万",
                floor: "8/32层",
                year: "2015年",
                description: "中等装修，业主诚心出售，交通便利",
                tags: ["中等装修", "业主诚心", "交通便利"],
                vrAvailable: true,
                vrCode: "sunshine-102"
            }
        ],
        2: [
            {
                id: 201,
                title: "和谐家园 4室2厅2卫",
                area: "150㎡",
                layout: "南北通透",
                price: "920万",
                floor: "12/28层",
                year: "2012年",
                description: "豪华装修，小区中心位置，安静舒适",
                tags: ["豪华装修", "中心位置", "安静舒适"],
                vrAvailable: true,
                vrCode: "harmony-201"
            },
            {
                id: 202,
                title: "和谐家园 3室1厅1卫",
                area: "105㎡",
                layout: "东南向",
                price: "630万",
                floor: "5/28层",
                year: "2012年",
                description: "简单装修，适合刚需家庭，周边配套齐全",
                tags: ["简单装修", "刚需首选", "配套齐全"],
                vrAvailable: false,
                vrCode: ""
            }
        ],
        3: [
            {
                id: 301,
                title: "幸福里 2室2厅1卫",
                area: "95㎡",
                layout: "南北通透",
                price: "580万",
                floor: "10/30层",
                year: "2016年",
                description: "精装修，业主自住，保养好，采光极佳",
                tags: ["精装修", "业主自住", "保养好", "采光极佳"],
                vrAvailable: true,
                vrCode: "happy-301"
            },
            {
                id: 302,
                title: "幸福里 1室1厅1卫",
                area: "60㎡",
                layout: "南向",
                price: "360万",
                floor: "18/30层",
                year: "2016年",
                description: "精装修，适合单身或小家庭，近地铁",
                tags: ["精装修", "单身首选", "近地铁"],
                vrAvailable: true,
                vrCode: "happy-302"
            }
        ],
        4: [
            {
                id: 401,
                title: "城市花园 3室2厅2卫",
                area: "130㎡",
                layout: "南北通透",
                price: "860万",
                floor: "20/35层",
                year: "2018年",
                description: "全新装修，未入住，小区环境优美，近公园",
                tags: ["全新装修", "未入住", "环境优美", "近公园"],
                vrAvailable: true,
                vrCode: "citygarden-401"
            },
            {
                id: 402,
                title: "城市花园 2室2厅1卫",
                area: "98㎡",
                layout: "东西通透",
                price: "620万",
                floor: "12/35层",
                year: "2018年",
                description: "精装修，拎包入住，视野好，采光充足",
                tags: ["精装修", "拎包入住", "视野好", "采光充足"],
                vrAvailable: false,
                vrCode: ""
            }
        ],
        5: [
            {
                id: 501,
                title: "金色年华 5室3厅3卫",
                area: "220㎡",
                layout: "南北通透",
                price: "1800万",
                floor: "15/25层",
                year: "2020年",
                description: "豪华装修，智能家居，小区安保严格，私密性好",
                tags: ["豪华装修", "智能家居", "安保严格", "私密性好"],
                vrAvailable: true,
                vrCode: "golden-501"
            },
            {
                id: 502,
                title: "金色年华 4室2厅2卫",
                area: "180㎡",
                layout: "南北通透",
                price: "1400万",
                floor: "10/25层",
                year: "2020年",
                description: "精装修，小区环境好，配套设施完善",
                tags: ["精装修", "环境好", "配套完善", "高端社区"],
                vrAvailable: true,
                vrCode: "golden-502"
            }
        ]
    };

    // 初始化地图
    function initMap() {
        var map = new AMap.Map("container", {
            resizeEnable: true,
            center: [116.479658, 39.998528],
            zoom: 15
        });

        // 添加小区标记点
        communityData.forEach(function(community) {
            // 创建自定义标记点
            var marker = new AMap.Marker({
                map: map,
                position: community.position,
                offset: new AMap.Pixel(-12, -24),
                title: community.name,
                // 自定义标记点样式
                content: `<div class="community-marker">
                            <div class="marker-pulse"></div>
                            <div class="marker-pulse"></div>
                            <div class="marker-content">
                                ${community.id}
                            </div>
                          </div>`
            });

            // 为标记点添加点击事件
            marker.on('click', function() {
                showHouseInfo(community);
            });

            // 生成小区标签HTML
            const communityTagsHtml = community.tags ? community.tags.map(tag => 
                `<span style="display:inline-block;padding:2px 6px;background:#e8f0fe;color:#667eea;border-radius:10px;font-size:11px;margin-right:4px;margin-bottom:4px;">${tag}</span>`
            ).join('') : '';
            
            // 添加信息窗口
            var infoWindow = new AMap.InfoWindow({
                content: `<div style="padding:12px;min-width:200px;">
                            <h3 style="margin:0 0 8px 0;color:#333;"><i class="fas fa-building" style="margin-right:6px;color:#667eea;"></i>${community.name}</h3>
                            <p style="margin:0 0 10px 0;color:#666;font-size:13px;line-height:1.4;">${community.description}</p>
                            <div style="margin-bottom:10px;">${communityTagsHtml}</div>
                            <button style="margin-top:8px;padding:6px 16px;background:linear-gradient(135deg, #667eea, #764ba2);color:white;border:none;border-radius:6px;cursor:pointer;font-size:13px;transition:all 0.3s;
                                        box-shadow:0 2px 6px rgba(102, 126, 234, 0.3);" 
                                    onclick="showHouseInfo(${community.id});event.stopPropagation();">
                                <i class="fas fa-search"></i> 查看房源
                            </button>
                          </div>`,
                offset: new AMap.Pixel(0, -30),
                isCustom: true,
                autoMove: true,
                closeWhenClickMap: true
            });

            marker.on('mouseover', function() {
                infoWindow.open(map, community.position);
            });

            marker.on('mouseout', function() {
                infoWindow.close();
            });
        });

        // 添加地图点击事件，关闭房源信息面板
        map.on('click', function() {
            closeHouseInfo();
        });

        return map;
    }

    // 显示房源信息
    function showHouseInfo(community) {
        // 如果传入的是community对象
        if (typeof community === 'object') {
            const communityId = community.id;
            const communityName = community.name;
            const houseList = mockHouseData[communityId] || [];
            
            // 更新面板标题
            document.getElementById('communityName').textContent = communityName + " - 房源信息";
            
            // 清空并填充房源列表
            const houseListElement = document.getElementById('houseList');
            houseListElement.innerHTML = '';
            
            if (houseList.length === 0) {
                houseListElement.innerHTML = '<p style="text-align:center;color:#999;padding:20px;">暂无房源信息</p>';
            } else {
                houseList.forEach(function(house) {
                    const houseItem = document.createElement('div');
                    houseItem.className = 'house-item';
                    // 生成房源标签HTML
                    const tagsHtml = house.tags ? house.tags.map(tag => 
                        `<span class="house-tag">${tag}</span>`
                    ).join('') : '';
                    
                    houseItem.innerHTML = `
                        <div class="house-title">
                            <span>${house.title}</span>
                            <span class="house-price">${house.price}</span>
                        </div>
                        <div class="house-info">
                            <p><i class="fas fa-expand-arrows-alt" style="margin-right:5px;color:#667eea;"></i>面积：${house.area} | 
                               <i class="fas fa-home" style="margin-right:5px;color:#667eea;"></i>户型：${house.layout} | 
                               <i class="fas fa-building" style="margin-right:5px;color:#667eea;"></i>楼层：${house.floor}</p>
                            <p><i class="fas fa-calendar-alt" style="margin-right:5px;color:#667eea;"></i>建成年代：${house.year}</p>
                            <p><i class="fas fa-comment" style="margin-right:5px;color:#667eea;"></i>${house.description}</p>
                        </div>
                        <div class="house-tags">
                            ${tagsHtml}
                        </div>
                        ${house.vrAvailable ? `
                        <div style="margin-top:12px;">
                            <button class="vr-view-btn" onclick="openVRView('${house.vrCode}', '${house.title}', '${communityName}')">
                                <i class="fas fa-vr-cardboard"></i> VR看房
                            </button>
                        </div>` : ''}
                    `;
                    houseListElement.appendChild(houseItem);
                });
            }
            
            // 显示面板
            document.getElementById('houseInfoPanel').classList.add('show');
        } else if (typeof community === 'number') {
            // 如果传入的是communityId
            const community = communityData.find(c => c.id === community);
            if (community) {
                showHouseInfo(community);
            }
        }
    }

    // 打开VR看房
    function openVRView(vrCode, houseTitle, communityName) {
        // 构造URL参数
        const params = new URLSearchParams();
        params.append('vrCode', vrCode);
        params.append('houseTitle', houseTitle);
        params.append('communityName', communityName);
        
        // 打开新的VR看房页面
        window.open(`vr.html?${params.toString()}`, '_blank', 'width=1024,height=768,scrollbars=yes');
    }

    // 页面加载完成后初始化地图
    window.onload = function() {
        initMap();
    };
</script>
</body>
</html>